cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sudo sysctl --system

# -----------------------------镜像源------------------------------------
apt-get update && apt-get install -y apt-transport-https

# 阿里云镜像源
curl -s https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | sudo apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
EOF

# docker 和 k8s 镜像源
#curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | apt-key add -
#curl -fsSL https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -
#cat <<EOF >/etc/apt/sources.list.d/docker-k8s.list
#deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
#deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable
#EOF


# 清华镜像源（不可用）
#sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
#cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
#deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://mirrors.tuna.tsinghua.edu.cn/kubernetes/apt kubernetes-xenial main
#EOF

# ------------------------------------------------------------------
# 下载 kubelet，kubeadm，kubectl
sudo apt-get update
# 查询有哪些版本
# apt-cache madison kubeadm
sudo apt-get install -y kubelet=1.23.17-00 kubeadm=1.23.17-00 kubectl=1.23.17-00
sudo apt-mark hold kubelet kubeadm kubectl

# completion
source <(kubectl completion bash)
source <(kubeadm completion bash)

sudo systemctl daemon-reload
sudo systemctl restart kubelet